
//启动的时候执行
function launch_exec() {
    //数组过滤元素返回并删除。参数可以是函数，数组(只要在数组中就删除)，数值
    Array.prototype.filterAndRemove = function(f) {
      if (f instanceof Function) {
          let result = []
          //在遍历中删除
          for (let i = this.length - 1; i >= 0; i--) {
              if(f(this[i])) {
                  result = [...result, ...this.splice(i, 1)]
              }
          }
          return result.reverse()

      } else if (f instanceof Array) {
        let result = []
        //在遍历中删除
        for (let i = this.length - 1; i >= 0; i--) {
            if(f.includes(this[i])) {
                result = [...result, ...this.splice(i, 1)]
            }
        }
        return result.reverse()

      } else {
          let result = []
          //在遍历中删除
          for (let i = this.length - 1; i >= 0; i--) {
              if(this[i] == f) {
                  result = [...result, ...this.splice(i, 1)]
              }
          }
          return result.reverse()

      }
    }

}

module.exports = {
  launch_exec
}